/* eslint-disable class-methods-use-this */
import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class City {
  async getCityList(page, limit, info) {
    const res = await get(`v1/city?page=${page}&limit=${limit}`, info)
    return res
  }

  async getCityAll(info) {
    const res = await get('v1/city_all', info)
    return res
  }

  async getCityInfo(id) {
    const res = await get(`v1/city/${id}`)
    return res
  }

  async createCity(info) {
    const res = await post('v1/city', info)
    return res
  }

  async updateCity(info) {
    const res = await put('v1/city', info)
    return res
  }

  async deleteCity(id) {
    const res = await _delete(`v1/city/${id}`)
    return res
  }
}

export default new City()
